home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / sys / scsi.new < prev    next >
Text File  |  1991-06-27  |  28KB  |  738 lines

  1. /*
  2.  * scsi.h --
  3.  *
  4.  *    Common declarations for SCSI command formaters. This file only covers
  5.  *    definitions pertaining to the SCSI common command set that are
  6.  *    common to all SCSI device types (ie disk, tapes, WORM, printers, etc).
  7.  *    Device sepecific command format can be found in scsi{Disk,Tape,WORM}.h
  8.  *    SCSI protocol releated declarations can be found in scsiHBA.h.
  9.  *    Definitions for the SCSI device sub-system. Some of the following
  10.  *      references from the proceedings of the 1984 Mini/Micro Northeast
  11.  *    Conference might be useful in understanding SCSI. 
  12.  *
  13.  *
  14.  * Copyright 1988 Regents of the University of California
  15.  * Permission to use, copy, modify, and distribute this
  16.  * software and its documentation for any purpose and without
  17.  * fee is hereby granted, provided that the above copyright
  18.  * notice appear in all copies.  The University of California
  19.  * makes no representations about the suitability of this
  20.  * software for any purpose.  It is provided "as is" without
  21.  * express or implied warranty.
  22.  *
  23.  * $Header: /sprite/src/lib/include/sys/RCS/scsi.h,v 1.1 91/06/25 15:20:22 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  24.  */
  25.  
  26. #ifndef _SCSI_H
  27. #define _SCSI_H
  28.  
  29. /*
  30.  * "Standard" SCSI Commands. SCSI command are divided into 8 group as
  31.  * follows:
  32.  *    Group0    (0x00 - 0x1f).  Basic commands. 6 bytes long
  33.  *    Group1    (0x20 - 0x3f).  Extended command. 10 bytes.
  34.  *    Group2    (0x40 - 0x5f).    Reserved.
  35.  *    Group2    (0x60 - 0x7f).    Reserved.
  36.  *    Group2    (0x80 - 0x9f).    Reserved.
  37.  *    Group2    (0xa0 - 0xbf).    Reserved.
  38.  *    Group6    (0xc0 - 0xdf).    Vendor Unique
  39.  *    Group7    (0xe0 - 0xff).  Vendor Unique
  40.  *    
  41.  *
  42.  */
  43.  
  44. /*
  45.  * Scsi Group0 commands all are 6 bytes and have a format according to 
  46.  * struct ScsiGroup0Cmd.
  47.  */
  48.  
  49. #define SCSI_TEST_UNIT_READY    0x00
  50. #define SCSI_REZERO_UNIT    0x01
  51. #define SCSI_REQUEST_SENSE    0x03
  52. #define    SCSI_FORMAT_UNIT    0x04
  53. #define SCSI_REASSIGN_BLOCKS    0x07
  54. #define SCSI_READ        0x08
  55. #define SCSI_WRITE        0x0a
  56. #define SCSI_SEEK        0x0b
  57. #define SCSI_INQUIRY        0x12
  58. #define SCSI_MODE_SELECT    0x15
  59. #define    SCSI_RESERVE_UNIT    0x16
  60. #define    SCSI_RELEASE_UNIT    0x17
  61. #define SCSI_COPY        0x18
  62. #define SCSI_MODE_SENSE        0x1A
  63. #define SCSI_START_STOP        0x1b
  64. #define    SCSI_RECV_DIAG_RESULTS    0x1c
  65. #define SCSI_SEND_DIAGNOSTIC    0x1d
  66. #define SCSI_PREVENT_ALLOW     0x1e
  67. /*
  68.  * Group1 commands are all 10 bytes and have a format according to
  69.  * struct ScsiGroup1Cmd.
  70.  */
  71. #define SCSI_READ_CAPACITY     0x25    
  72. #define    SCSI_READ_EXT        0x28
  73. #define    SCSI_WRITE_EXT        0x2a
  74. #define    SCSI_SEEK_EXT        0x2b
  75. #define    SCSI_WRITE_VERIFY    0x2e
  76. #define    SCSI_VERIFY_EXT        0x2f
  77. #define    SCSI_SEARCH_HIGH    0x30
  78. #define SCSI_SEARCH_EQUAL    0x31
  79. #define    SCSI_SEARCH_LOW        0x32
  80. #define    SCSI_SET_LIMITS        0x33
  81. #define    SCSI_COMPARE        0x39
  82. #define    SCSI_COPY_VERIFY    0x3a
  83.  
  84.  
  85. /*
  86.  * Group-0 commands for sequential access devices.
  87.  */
  88.  
  89. #define SCSI_REWIND        0x01
  90. #define SCSI_READ_BLOCK_LIMITS    0x05
  91. #define    SCSI_TRACK_SELECT    0x0b
  92. #define    SCSI_READ_REVERSE    0x0f
  93. #define SCSI_WRITE_EOF        0x10
  94. #define SCSI_SPACE        0x11
  95. #define    SCSI_VERIFY        0x13
  96. #define    SCSI_READ_BUFFER    0x14
  97. #define SCSI_ERASE_TAPE        0x19
  98. #define    SCSI_LOAD_UNLOAD    0x1b
  99.  
  100. /*
  101.  * Group-1 commands for sequential access devices.
  102.  */
  103. #define SCSI_READ_POSITION    0x34
  104.  
  105.  
  106. /*
  107.  * The standard group-0 6-byte SCSI control block.  Note that the 
  108.  * fields between highAddr and blockCount inclusive are command dependent.
  109.  * The definitions Addr and BlockCount cover most of the commands we will
  110.  * use.
  111.  */
  112.  
  113. typedef struct ScsiGroup0Cmd {
  114. #if BYTE_ORDER == BIG_ENDIAN
  115.     unsigned char command;        /* command code, defined below.  The
  116.                      * upper three bits of this are zero
  117.                      * to indicate the control block is
  118.                      * only 6 bytes long */
  119.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  120.                      * pass the command.  The device
  121.                      * has already been selected using
  122.                      * the "targetID" bit. */
  123.     unsigned char highAddr    :5;    /* High bits of address */
  124.     unsigned char midAddr;        /* Middle bits of address */
  125.     unsigned char lowAddr;        /* Low bits of address */
  126.     unsigned char blockCount;        /* Blocks to transfer */
  127.     unsigned char vendor57    :1;    /* Vendor unique bit */
  128.     unsigned char vendor56    :1;    /* Vendor unique bit */
  129.     unsigned char pad1        :4;    /* Reserved */
  130.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  131.     unsigned char link        :1;    /* Another command follows */
  132. #else
  133.     unsigned char command;        /* command code, defined below.  The
  134.                      * upper three bits of this are zero
  135.                      * to indicate the control block is
  136.                      * only 6 bytes long */
  137.     unsigned char highAddr    :5;    /* High bits of address */
  138.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  139.                      * pass the command.  The device
  140.                      * has already been selected using
  141.                      * the "targetID" bit. */
  142.     unsigned char midAddr;        /* Middle bits of address */
  143.     unsigned char lowAddr;        /* Low bits of address */
  144.     unsigned char blockCount;        /* Blocks to transfer */
  145.     unsigned char link        :1;        /* Another command follows */
  146.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  147.     unsigned char pad1        :4;    /* Reserved */
  148.     unsigned char vendor56    :1;    /* Vendor unique bit */
  149.     unsigned char vendor57    :1;    /* Vendor unique bit */
  150. #endif
  151. } ScsiGroup0Cmd;
  152.  
  153. /*
  154.  * SCSI status completion information.  This is returned by the device
  155.  * when a command completes. 
  156.  */
  157.  
  158. typedef struct ScsiStatus {
  159. #if BYTE_ORDER == BIG_ENDIAN
  160.     unsigned char reserved    :1;    /* Reserved. */
  161.     unsigned char vendor06    :1;    /* Vendor unique bit */
  162.     unsigned char vendor05    :1;    /* Vendor unique bit */
  163.     unsigned char intStatus    :1;    /* Intermediate status */
  164.     unsigned char busy        :1;    /* Device busy or reserved */
  165.     unsigned char conditionMet    :1;    /* Condition met */
  166.     unsigned char check        :1;    /* Check the sense data for more info */
  167.     unsigned char vendor00    :1;    /* Vendor unique bit */
  168. #else
  169.     unsigned char vendor00    :1;    /* Vendor unique bit */
  170.     unsigned char check        :1;    /* Check the sense data for more info */
  171.     unsigned char conditionMet    :1;    /* Condition met */
  172.     unsigned char busy        :1;    /* Device busy or reserved */
  173.     unsigned char intStatus    :1;    /* Intermediate status */
  174.     unsigned char vendor05    :1;    /* Vendor unique bit */
  175.     unsigned char vendor06    :1;    /* Vendor unique bit */
  176.     unsigned char reserved    :1;    /* Reserved. */
  177. #endif
  178. } ScsiStatus;
  179.  
  180. /*
  181.  * SCSI_RESERVED_STATUS() - Return TRUE if the status byte has a reserved code.
  182.  */
  183.  
  184. #define    SCSI_RESERVED_STATUS(byte) (byte&0x80)
  185.  
  186.  
  187. /*
  188.  * Sense information provided after some errors.  This is divided into
  189.  * two kinds, classes 0-6, and class 7.  This is 30 bytes big to allow
  190.  * for the drive specific sense bytes that follow the standard 4 byte header.
  191.  *
  192.  * For extended sense, this buffer may be cast into another type.  Also
  193.  * The actual size of the sense data returned is used to detect what
  194.  * kind of tape drive is out there.  Kludgy, but true.
  195.  */
  196. typedef struct ScsiClass0Sense {
  197. #if BYTE_ORDER == BIG_ENDIAN
  198.     unsigned char valid        :1;    /* Sense data is valid */
  199.     unsigned char error        :7;    /* 3 bits class and 4 bits code */
  200.     unsigned char highAddr;        /* High byte of block address */
  201.     unsigned char midAddr;        /* Middle byte of block address */
  202.     unsigned char lowAddr;        /* Low byte of block address */
  203.     unsigned char sense[26];        /* Target specific sense data */
  204. #else
  205.     unsigned char error        :7;    /* 3 bits class and 4 bits code */
  206.     unsigned char valid        :1;    /* Sense data is valid */
  207.     unsigned char highAddr;        /* High byte of block address */
  208.     unsigned char midAddr;        /* Middle byte of block address */
  209.     unsigned char lowAddr;        /* Low byte of block address */
  210.     unsigned char sense[26];        /* Target specific sense data */
  211. #endif
  212. } ScsiClass0Sense;
  213.  
  214. /*
  215.  * Definitions for errors in the sense data.  The error field is specified
  216.  * as a 3 bit class and 4 bit code, but it is easier to treat it as a
  217.  * single 7 bit field.
  218.  */
  219. #define SCSI_NO_SENSE_DATA        0x00
  220. #define SCSI_NOT_READY            0x04
  221. #define SCSI_NOT_LOADED            0x09
  222. #define SCSI_INSUF_CAPACITY        0x0a
  223. #define SCSI_HARD_DATA_ERROR        0x11
  224. #define SCSI_WRITE_PROTECT        0x17
  225. #define SCSI_CORRECTABLE_ERROR        0x18
  226. #define SCSI_FILE_MARK            0x1c
  227. #define SCSI_INVALID_COMMAND        0x20
  228. #define SCSI_UNIT_ATTENTION        0x30
  229. #define SCSI_END_OF_MEDIA        0x34
  230.  
  231. /*
  232.  * The standard "extended" sense data returned by SCSI devices.  This
  233.  * has an error field of 0x70, for a "class 7" error.
  234.  */
  235. typedef struct ScsiClass7Sense {
  236. #if BYTE_ORDER == BIG_ENDIAN
  237.     unsigned char valid        :1;    /* Sense data is valid */
  238.     unsigned char error7    :7;    /* == 0x70 */
  239.     unsigned char pad1;            /* Also "segment number" for copy */
  240.     unsigned char fileMark    :1;    /* File mark on device */
  241.     unsigned char endOfMedia    :1;    /* End of media reached */
  242.     unsigned char badBlockLen    :1;    /* Block length mis-match (Exabyte) */
  243.     unsigned char pad2        :1;
  244.     unsigned char key        :4;    /* Sense keys defined below */
  245.     unsigned char info1;        /* Information byte 1 */
  246.     unsigned char info2;        /* Information byte 2 */
  247.     unsigned char info3;        /* Information byte 3 */
  248.     unsigned char info4;        /* Information byte 4 */
  249.     unsigned char length;        /* Number of additional info bytes */
  250. #else
  251.     unsigned char error7    :7;    /* == 0x70 */
  252.     unsigned char valid        :1;    /* Sense data is valid */
  253.     unsigned char pad1;            /* Also "segment number" for copy */
  254.     unsigned char key        :4;    /* Sense keys defined below */
  255.     unsigned char pad2        :1;
  256.     unsigned char badBlockLen    :1;    /* Block length mis-match (Exabyte) */
  257.     unsigned char endOfMedia    :1;    /* End of media reached */
  258.     unsigned char fileMark    :1;    /* File mark on device */
  259.     unsigned char info1;        /* Information byte 1 */
  260.     unsigned char info2;        /* Information byte 2 */
  261.     unsigned char info3;        /* Information byte 3 */
  262.     unsigned char info4;        /* Information byte 4 */
  263.     unsigned char length;        /* Number of additional info bytes */
  264. #endif
  265. } ScsiClass7Sense;            /* 8 Bytes */
  266.  
  267. /*
  268.  * Key values for standardized sense class 7. 
  269.  */
  270. #define SCSI_CLASS7_NO_SENSE        0
  271. #define SCSI_CLASS7_RECOVERABLE    1
  272. #define SCSI_CLASS7_NOT_READY        2
  273. #define SCSI_CLASS7_MEDIA_ERROR    3
  274. #define SCSI_CLASS7_HARDWARE_ERROR    4
  275. #define SCSI_CLASS7_ILLEGAL_REQUEST    5
  276.  
  277. /*
  278.  * These seem to have different meanings to different vendors....
  279.  */
  280. #define SCSI_CLASS7_MEDIA_CHANGE    6
  281. #define SCSI_CLASS7_UNIT_ATTN        6
  282.  
  283. #define SCSI_CLASS7_WRITE_PROTECT    7
  284. #define SCSI_CLASS7_BLANK_CHECK        8
  285. #define SCSI_CLASS7_VENDOR        9
  286. #define SCSI_CLASS7_POWER_UP_FAILURE    10
  287. #define SCSI_CLASS7_ABORT        11
  288. #define SCSI_CLASS7_EQUAL        12
  289. #define SCSI_CLASS7_OVERFLOW        13
  290. #define SCSI_CLASS7_RESERVED_14        14
  291. #define SCSI_CLASS7_RESERVED_15        15
  292.  
  293. /*
  294.  * Maximum size of sense data that a device can return. XXX - fix this.
  295.  */
  296. #define    SCSI_MAX_SENSE_LEN    64
  297.  
  298. /*
  299.  * Data return by the SCSI inquiry command. 
  300.  */
  301.  
  302. typedef struct ScsiInquiryData {
  303. #if BYTE_ORDER == BIG_ENDIAN
  304.     unsigned char     type;        /* Peripheral Device type. See below. */
  305.     unsigned char     rmb:1;        /* Removable Medium bit. */
  306.     unsigned char    qualifier:7;     /* Device type qualifier. */
  307.     unsigned char    version;    /* Version info. */
  308.     unsigned char    reserved:4;    /* reserved. */
  309.     unsigned char    format:4;    /* Response format. */
  310.     unsigned char    length;        /* length of data returned. */
  311. #ifdef notdef
  312.     unsigned char    vendor;        /* Vendor unqiue parameter. */
  313.     unsigned char    reserved2[2];    /* More reserved. */
  314.     char        vendorInfo[8];    /* Vector identification. */
  315.     char        productInfo[8]; /* Product identification. */
  316.     char        firmwareInfo[4]; /* Firmware identification. */
  317. #endif
  318.  
  319.     unsigned char    reserved2[3];    /* Reserved                  */
  320.     unsigned char    vendorID[8];    /* Vendor ID (ASCII)              */
  321.     unsigned char    productID[16];    /* Product ID (ASCII)              */
  322.     unsigned char    revLevel[4];    /* Revision level (ASCII)          */
  323.     unsigned char    revData[8];    /* Revision data (ASCII)          */
  324. #else
  325.     unsigned char     type;        /* Peripheral Device type. See below. */
  326.     unsigned char    qualifier:7;     /* Device type qualifier. */
  327.     unsigned char     rmb:1;        /* Removable Medium bit. */
  328.     unsigned char    version;    /* Version info. */
  329.     unsigned char    format:4;    /* Response format. */
  330.     unsigned char    reserved:4;    /* reserved. */
  331.     unsigned char    length;        /* length of data returned. */
  332.     unsigned char    reserved2[3];    /* Reserved                  */
  333.     unsigned char    vendorID[8];    /* Vendor ID (ASCII)              */
  334.     unsigned char    productID[16];    /* Product ID (ASCII)              */
  335.     unsigned char    revLevel[4];    /* Revision level (ASCII)          */
  336.     unsigned char    revData[8];    /* Revision data (ASCII)          */
  337. #endif
  338. }  ScsiInquiryData;
  339.  
  340.  
  341. /*
  342.  * The SCSI Peripheral type ID codes as return by the SCSI_INQUIRY command.
  343.  *
  344.  * SCSI_DISK_TYPE - Direct Access Device.
  345.  * SCSI_TAPE_TYPE - Sequential Access Device.
  346.  * SCSI_PRINTER_TYPE - Printer Device.
  347.  * SCSI_HOST_TYPE - Processor Device.
  348.  * SCSI_WORM_TYPE - Write-Once Read-Multiple Device.
  349.  * SCSI_ROM_TYPE  - Read-Only Direct Access Device.
  350.  * SCSI_SCANNER_TYPE - Scanner device.
  351.  * SCSI_OPTICAL_MEM_TYPE - Optical memory device.
  352.  * SCSI_MEDIUM_CHANGER_TYPE - Medium changer device.
  353.  * SCSI_COMMUNICATIONS_TYPE - Communications device.
  354.  * SCSI_NODEVICE_TYPE - Logical Unit not present or implemented.
  355.  *
  356.  * Note that codes 0xa-0x7e are reserved and 0x80-0xff are vendor unique.
  357.  */
  358. #define    SCSI_DISK_TYPE        0
  359. #define    SCSI_TAPE_TYPE        1
  360. #define    SCSI_PRINTER_TYPE    2
  361. #define    SCSI_HOST_TYPE        3
  362. #define    SCSI_WORM_TYPE        4
  363. #define    SCSI_ROM_TYPE        5
  364. #define    SCSI_SCANNER_TYPE    6
  365. #define    SCSI_OPTICAL_MEM_TYPE    7
  366. #define    SCSI_MEDIUM_CHANGER_TYPE    8
  367. #define    SCSI_COMMUNICATIONS_TYPE    9
  368. #define    SCSI_NODEVICE_TYPE    0x7f
  369.  
  370. /*
  371.  * Standard header for SCSI_MODE_SELECT commands for tapes.
  372.  */
  373.  
  374. typedef struct ScsiTapeModeSelectHdr {
  375. #if BYTE_ORDER == BIG_ENDIAN
  376.     unsigned char    reserved[2];    /* Reserved. */
  377.     unsigned char    reserved2:1;    /*  ""         */
  378.     unsigned char    bufferedMode:3;    /* Type of buffer to be done. */
  379.     unsigned char    speed:4;    /* Drive speed. */
  380.     unsigned char    length;        /* Block descriptor length. */
  381. #else
  382.     unsigned char    reserved[2];    /* Reserved. */
  383.     unsigned char    speed:4;    /* Drive speed. */
  384.     unsigned char    bufferedMode:3;    /* Type of buffer to be done. */
  385.     unsigned char    reserved2:1;    /*  ""         */
  386.     unsigned char    length;        /* Block descriptor length. */
  387. #endif
  388. } ScsiTapeModeSelectHdr;
  389. /*
  390.  * Format of a SCSI_START_STOP command. This is a group 0 command, but
  391.  * the command contents are different.
  392.  */
  393. typedef struct ScsiStartStopCmd {
  394. #if BYTE_ORDER == BIG_ENDIAN
  395.     unsigned char command;        /* 0x1b */
  396.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  397.                      * pass the command.  The device
  398.                      * has already been selected using
  399.                      * the "targetID" bit. */
  400.     unsigned char pad1        :4;    /* Reserved */
  401.     unsigned char immed        :1;    /* Immediate status bit */
  402.     unsigned char pad2;            /* Reserved */
  403.     unsigned char pad3;            /* Reserved */
  404.     unsigned char pad4        :6;    /* Reserved */
  405.     unsigned char loadEject    :1;    /* Load or eject medium */
  406.     unsigned char start        :1;    /* Start or stop medium */
  407.     unsigned char vendor57    :1;    /* Vendor unique bit */
  408.     unsigned char vendor56    :1;    /* Vendor unique bit */
  409.     unsigned char pad5        :4;    /* Reserved */
  410.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  411.     unsigned char link        :1;    /* Another command follows */
  412. #else
  413.     unsigned char command;        /* command code, defined below.  The
  414.                      * upper three bits of this are zero
  415.                      * to indicate the control block is
  416.                      * only 6 bytes long */
  417.     unsigned char immed        :1;    /* Immediate status bit */
  418.     unsigned char pad1        :4;    /* Reserved */
  419.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  420.                      * pass the command.  The device
  421.                      * has already been selected using
  422.                      * the "targetID" bit. */
  423.     unsigned char pad2;            /* Reserved */
  424.     unsigned char pad3;            /* Reserved */
  425.     unsigned char start        :1;    /* Start or stop medium */
  426.     unsigned char loadEject    :1;    /* Load or eject medium */
  427.     unsigned char pad4        :6;    /* Reserved */
  428.     unsigned char link        :1;    /* Another command follows */
  429.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  430.     unsigned char pad5        :4;    /* Reserved */
  431.     unsigned char vendor56    :1;    /* Vendor unique bit */
  432.     unsigned char vendor57    :1;    /* Vendor unique bit */
  433. #endif
  434. } ScsiStartStopCmd;
  435.  
  436.  
  437. /*
  438.  * Format of a SCSI_READ_EXT command.
  439.  */
  440.  
  441. typedef struct ScsiReadExtCmd {
  442. #if BYTE_ORDER == BIG_ENDIAN
  443.     unsigned char command;        /* command code. */
  444.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  445.                      * pass the command.  The device
  446.                      * has already been selected using
  447.                      * the "targetID" bit. */
  448.     unsigned char dpo        :1;    /* Disable page out. */
  449.     unsigned char fua        :1;    /* Force unit access. */
  450.     unsigned char pad1        :2;    /* Reserved. */
  451.     unsigned char relAddr    :1;    /* Who knows? */
  452.     unsigned char highAddr;        /* High bits of address. */
  453.     unsigned char highMidAddr;        /* High middle bits of address. */
  454.     unsigned char lowMidAddr;        /* Low middle bits of address. */
  455.     unsigned char lowAddr;        /* Low bits of address */
  456.     unsigned char pad2;            /* Reserved. */
  457.     unsigned char highCount;        /* High bits of number to transfer */
  458.     unsigned char lowCount;        /* Low bits of number to transfer */
  459.     unsigned char vendor    :2;    /* Vendor specific. */
  460.     unsigned char pad        :4;    /* Reserved. */
  461.     unsigned char flag        :1;    /* Flag bit. See SCSI doc. */
  462.     unsigned char link        :1;    /* Link commands. */
  463. #else
  464.     unsigned char command;        /* command code. */
  465.     unsigned char relAddr    :1;    /* Who knows? */
  466.     unsigned char pad1        :2;    /* Reserved. */
  467.     unsigned char fua        :1;    /* Force unit access. */
  468.     unsigned char dpo        :1;    /* Disable page out. */
  469.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  470.                      * pass the command.  The device
  471.                      * has already been selected using
  472.                      * the "targetID" bit. */
  473.     unsigned char highAddr;        /* High bits of address. */
  474.     unsigned char highMidAddr;        /* High middle bits of address. */
  475.     unsigned char lowMidAddr;        /* Low middle bits of address. */
  476.     unsigned char lowAddr;        /* Low bits of address */
  477.     unsigned char pad2;            /* Reserved. */
  478.     unsigned char highCount;        /* High bits of number to transfer */
  479.     unsigned char lowCount;        /* Low bits of number to transfer */
  480.     unsigned char link        :1;    /* Link commands. */
  481.     unsigned char flag        :1;    /* Flag bit. See SCSI doc. */
  482.     unsigned char pad        :4;    /* Reserved. */
  483.     unsigned char vendor    :2;    /* Vendor specific. */
  484. #endif
  485. } ScsiReadExtCmd;
  486.  
  487. /*
  488.  * The SCSI_WRITE_EXT command had the same format as SCSI_READ_EXT.
  489.  */
  490.  
  491. typedef struct ScsiReadExtCmd ScsiWriteExtCmd;
  492.  
  493. /* 
  494.  * Data returned by the SCSI_READ_BLOCK_LIMITS command.
  495.  */
  496.  
  497. typedef struct {
  498.     unsigned char    pad1;
  499.     unsigned char    max2;    /* MSB of max block size. */
  500.     unsigned char    max1;    /* ... */
  501.     unsigned char    max0;    /* LSB of max block size. */
  502.     unsigned char    min1;    /* MSB of min block size. */
  503.     unsigned char    min0;    /* LSB of min block size. */
  504. } ScsiBlockLimits;
  505.  
  506. /*
  507.  * Format of a SCSI_MODE_SENSE command. 
  508.  */
  509. typedef struct {
  510. #if BYTE_ORDER == BIG_ENDIAN
  511.     unsigned char command;        /* 0x1b */
  512.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  513.                      * pass the command.  The device
  514.                      * has already been selected using
  515.                      * the "targetID" bit. */
  516.     unsigned char pad1        :1;    /* Reserved */
  517.     unsigned char disableBlockDesc :1;    /* Disable block descriptor */
  518.     unsigned char pad2        :3;    /* Reserved */
  519.     unsigned char pageControl    :2;    /* Page Control */
  520.     unsigned char pageCode    :6;    /* Page Code */
  521.     unsigned char pad3;            /* Reserved */
  522.     unsigned char allocLen;        /* Allocation length. */
  523.     unsigned char vendor    :2;    /* Vendor unique. */
  524.     unsigned char pad4        :6;    /* Reserved */
  525. #else
  526.     unsigned char command;        /* 0x1b */
  527.     unsigned char pad2        :3;    /* Reserved */
  528.     unsigned char disableBlockDesc :1;    /* Disable block descriptor */
  529.     unsigned char pad1        :1;    /* Reserved */
  530.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  531.                      * pass the command.  The device
  532.                      * has already been selected using
  533.                      * the "targetID" bit. */
  534.     unsigned char pageCode    :6;    /* Page Code */
  535.     unsigned char pageControl    :2;    /* Page Control */
  536.     unsigned char pad3;            /* Reserved */
  537.     unsigned char allocLen;        /* Allocation length. */
  538.     unsigned char pad4        :6;    /* Reserved */
  539.     unsigned char vendor    :2;    /* Vendor unique. */
  540. #endif
  541. } ScsiModeSenseCmd;
  542.  
  543. /*
  544.  * Block descriptor returned by mode sense.
  545.  */
  546.  
  547. typedef struct {
  548.     unsigned char    density;    /* Density code. */
  549.     unsigned char    num2;        /* MSB of number of blocks. */
  550.     unsigned char    num1;        /* ... */
  551.     unsigned char    num0;        /* LSB of number of blocks. */
  552.     unsigned char    pad0;        /* Reserved. */
  553.     unsigned char    len2;        /* MSB of block length. */
  554.     unsigned char    len1;        /* ... */
  555.     unsigned char    len0;        /* LSB of block length. */
  556. } ScsiBlockDesc;
  557.  
  558. /*
  559.  * Format of a SCSI_REQUEST_SENSE command.
  560.  */
  561. typedef struct {
  562. #if BYTE_ORDER == BIG_ENDIAN
  563.     unsigned char command;        /* 0x1b */
  564.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  565.                      * pass the command.  The device
  566.                      * has already been selected using
  567.                      * the "targetID" bit. */
  568.     unsigned char pad1        :5;    /* Reserved */
  569.     unsigned char pad2;            /* Reserved */
  570.     unsigned char pad3;            /* Reserved */
  571.     unsigned char allocLen;        /* Allocation length. */
  572.     unsigned char clearCount    :1;    /* Clear counters. */
  573.     unsigned char vendor    :1;    /* Vendor unique. */
  574.     unsigned char pad4        :6;    /* Reserved */
  575. #else
  576.     unsigned char command;        /* 0x1b */
  577.     unsigned char pad1        :5;    /* Reserved */
  578.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  579.                      * pass the command.  The device
  580.                      * has already been selected using
  581.                      * the "targetID" bit. */
  582.     unsigned char pad2;            /* Reserved */
  583.     unsigned char pad3;            /* Reserved */
  584.     unsigned char allocLen;        /* Allocation length. */
  585.     unsigned char pad4        :6;    /* Reserved */
  586.     unsigned char vendor    :1;    /* Vendor unique. */
  587.     unsigned char clearCount    :1;    /* Clear counters. */
  588. #endif
  589. } ScsiRequestSenseCmd;
  590.  
  591. /*
  592.  * Format of a SCSI_READ_POSITION command.
  593.  */
  594.  
  595. typedef struct {
  596. #if BYTE_ORDER == BIG_ENDIAN
  597.     unsigned char command;        /* 0x34 */
  598.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  599.                      * pass the command.  The device
  600.                      * has already been selected using
  601.                      * the "targetID" bit. */
  602.     unsigned char pad1        :4;    /* Reserved */
  603.     unsigned char blockType    :1;    /* Block type. */
  604.     unsigned char pad2;            /* Reserved */
  605.     unsigned char pad3;            /* Reserved */
  606.     unsigned char pad4;            /* Reserved */
  607.     unsigned char pad5;            /* Reserved */
  608.     unsigned char pad6;            /* Reserved */
  609.     unsigned char pad7;            /* Reserved */
  610.     unsigned char pad8;            /* Reserved */
  611.     unsigned char vendor    :2;    /* Vendor unique. */
  612.     unsigned char pad9        :6;    /* Reserved */
  613. #else
  614.     unsigned char command;        /* 0x34 */
  615.     unsigned char blockType    :1;    /* Block type. */
  616.     unsigned char pad1        :4;    /* Reserved */
  617.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  618.                      * pass the command.  The device
  619.                      * has already been selected using
  620.                      * the "targetID" bit. */
  621.     unsigned char pad2;            /* Reserved */
  622.     unsigned char pad3;            /* Reserved */
  623.     unsigned char pad4;            /* Reserved */
  624.     unsigned char pad5;            /* Reserved */
  625.     unsigned char pad6;            /* Reserved */
  626.     unsigned char pad7;            /* Reserved */
  627.     unsigned char pad8;            /* Reserved */
  628.     unsigned char pad9        :6;    /* Reserved */
  629.     unsigned char vendor    :2;    /* Vendor unique. */
  630. #endif
  631. } ScsiReadPositionCmd;
  632.  
  633. /*
  634.  * Result of a SCSI_READ_POSITION command.
  635.  */
  636.  
  637. typedef struct {
  638. #if BYTE_ORDER == BIG_ENDIAN
  639.     unsigned char bop        :1;    /* Beginning of partition. */
  640.     unsigned char eop        :1;    /* End of partition. */
  641.     unsigned char pad0a        :3;    /* Reserved. */
  642.     unsigned char bpu        :1;    /* Block position unknown. */
  643.     unsigned char pad0b        :2;    /* Reserved. */
  644.     unsigned char partition;        /* Partition number. */
  645.     unsigned char pad2;            /* Reserved. */
  646.     unsigned char pad3;            /* Reserved. */
  647.     unsigned char firstBlock3;        /* First block location, MSB */
  648.     unsigned char firstBlock2;        /* ... */
  649.     unsigned char firstBlock1;        /* ... */
  650.     unsigned char firstBlock0;        /* First block location, LSB */
  651.     unsigned char lastBlock3;        /* Last block location, MSB */
  652.     unsigned char lastBlock2;        /* ... */
  653.     unsigned char lastBlock1;        /* ... */
  654.     unsigned char lastBlock0;        /* Last block location, LSB */
  655.     unsigned char pad12;        /* Reserved. */
  656.     unsigned char blocksInBuf2;        /* Blocks in buffer, MSB. */
  657.     unsigned char blocksInBuf1;        /* ... */
  658.     unsigned char blocksInBuf0;        /* Blocks in buffer, LSB. */
  659.     unsigned char bytesInBuf3;        /* Bytes in buffer, MSB. */
  660.     unsigned char bytesInBuf2;        /* ... */
  661.     unsigned char bytesInBuf1;        /* ... */
  662.     unsigned char bytesInBuf0;        /* Bytes in buffer, LSB. */
  663. #else
  664.     unsigned char pad0b        :2;    /* Reserved. */
  665.     unsigned char bpu        :1;    /* Block position unknown. */
  666.     unsigned char pad0a        :3;    /* Reserved. */
  667.     unsigned char eop        :1;    /* End of partition. */
  668.     unsigned char bop        :1;    /* Beginning of partition. */
  669.     unsigned char partition;        /* Partition number. */
  670.     unsigned char pad2;            /* Reserved. */
  671.     unsigned char pad3;            /* Reserved. */
  672.     unsigned char firstBlock3;        /* First block location, MSB */
  673.     unsigned char firstBlock2;        /* ... */
  674.     unsigned char firstBlock1;        /* ... */
  675.     unsigned char firstBlock0;        /* First block location, LSB */
  676.     unsigned char lastBlock3;        /* Last block location, MSB */
  677.     unsigned char lastBlock2;        /* ... */
  678.     unsigned char lastBlock1;        /* ... */
  679.     unsigned char lastBlock0;        /* Last block location, LSB */
  680.     unsigned char pad12;        /* Reserved. */
  681.     unsigned char blocksInBuf2;        /* Blocks in buffer, MSB. */
  682.     unsigned char blocksInBuf1;        /* ... */
  683.     unsigned char blocksInBuf0;        /* Blocks in buffer, LSB. */
  684.     unsigned char bytesInBuf3;        /* Bytes in buffer, MSB. */
  685.     unsigned char bytesInBuf2;        /* ... */
  686.     unsigned char bytesInBuf1;        /* ... */
  687.     unsigned char bytesInBuf0;        /* Bytes in buffer, LSB. */
  688. #endif
  689. } ScsiReadPositionResult;
  690.  
  691. /*
  692.  * Format of SCSI_LOCATE command.
  693.  */
  694.  
  695. typedef struct {
  696. #if BYTE_ORDER == BIG_ENDIAN
  697.     unsigned char command;        /* 0x2b */
  698.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  699.                      * pass the command.  The device
  700.                      * has already been selected using
  701.                      * the "targetID" bit. */
  702.     unsigned char pad1        :2;    /* Reserved */
  703.     unsigned char blockType    :1;    /* Block type. */
  704.     unsigned char changePartition :1;    /* Change partitions. */
  705.     unsigned char immediate    :1;    /* Immediate. */
  706.     unsigned char pad2;            /* Reserved */
  707.     unsigned char addr3;        /* Block address, MSB */
  708.     unsigned char addr2;        /* ... */
  709.     unsigned char addr1;        /* ... */
  710.     unsigned char addr0;        /* Block address, LSB */
  711.     unsigned char pad7;            /* Reserved */
  712.     unsigned char partition;        /* Partition */
  713.     unsigned char vendor    :2;    /* Vendor unique. */
  714.     unsigned char pad9        :6;    /* Reserved */
  715. #else
  716.     unsigned char command;        /* 0x2b */
  717.     unsigned char immediate    :1;    /* Immediate. */
  718.     unsigned char changePartition :1;    /* Change partitions. */
  719.     unsigned char blockType    :1;    /* Block type. */
  720.     unsigned char pad1        :2;    /* Reserved */
  721.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  722.                      * pass the command.  The device
  723.                      * has already been selected using
  724.                      * the "targetID" bit. */
  725.     unsigned char pad2;            /* Reserved */
  726.     unsigned char addr3;        /* Block address, MSB */
  727.     unsigned char addr2;        /* ... */
  728.     unsigned char addr1;        /* ... */
  729.     unsigned char addr0;        /* Block address, LSB */
  730.     unsigned char pad7;            /* Reserved */
  731.     unsigned char partition;        /* Partition */
  732.     unsigned char pad9        :6;    /* Reserved */
  733.     unsigned char vendor    :2;    /* Vendor unique. */
  734. #endif
  735. } ScsiLocateCmd;
  736.  
  737. #endif /* _SCSI_H */
  738.